<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>Swarm Trajectory Planning: src/graph.cpp File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Swarm Trajectory Planning
   </div>
   <div id="projectbrief">Contains tools for measuring UAV swarm performance when flying through a path graph and allows the UAV swarm to fly through a generated graph.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">graph.cpp File Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>Contains definitions of functions for representing the graph of paths and for path finding.  
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &quot;../headers/graph.h&quot;</code><br />
</div><div class="textblock"><div class="dynheader">
Include dependency graph for graph.cpp:</div>
<div class="dyncontent">
<div class="center"><img src="graph_8cpp__incl.png" border="0" usemap="#src_2graph_8cpp" alt=""/></div>
<map name="src_2graph_8cpp" id="src_2graph_8cpp">
<area shape="rect" id="node2" href="graph_8h_source.html" title="../headers/graph.h" alt="" coords="337,80,463,107"/>
</map>
</div>
</div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a4f76dec25df84647976b08cf172ab9b1"><td class="memItemLeft" align="right" valign="top">vector&lt; int &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="graph_8cpp.html#a4f76dec25df84647976b08cf172ab9b1">find_path</a> (const string &amp;fpath, int flock_size, int source_idx, int goal_idx)</td></tr>
<tr class="separator:a4f76dec25df84647976b08cf172ab9b1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9fba6aac78b4b7e5cddcc5c037ad6199"><td class="memItemLeft" align="right" valign="top">double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="graph_8cpp.html#a9fba6aac78b4b7e5cddcc5c037ad6199">evaluate_edge</a> (vector&lt; double &gt; n1, vector&lt; double &gt; n2, int flock_size, double gap)</td></tr>
<tr class="separator:a9fba6aac78b4b7e5cddcc5c037ad6199"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3fb0b3ab7cf6e09976ac5f8e075ade7a"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="graph_8cpp.html#a3fb0b3ab7cf6e09976ac5f8e075ade7a">minDistance</a> (double dist[], bool sptSet[], unsigned long vnum)</td></tr>
<tr class="separator:a3fb0b3ab7cf6e09976ac5f8e075ade7a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a401501404aa387d4852fcc2a9ff3ad2d"><td class="memItemLeft" align="right" valign="top">vector&lt; int &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="graph_8cpp.html#a401501404aa387d4852fcc2a9ff3ad2d">get_path</a> (int parent[], int j, vector&lt; int &gt; out)</td></tr>
<tr class="separator:a401501404aa387d4852fcc2a9ff3ad2d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7f0876063956a2c9f083434f30d8abd3"><td class="memItemLeft" align="right" valign="top">vector&lt; int &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="graph_8cpp.html#a7f0876063956a2c9f083434f30d8abd3">dijkstra</a> (vector&lt; vector&lt; double &gt;&gt; graph, int src, int goal, unsigned long vnum)</td></tr>
<tr class="separator:a7f0876063956a2c9f083434f30d8abd3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac83a486cf316213a12cbffd5598b2fdd"><td class="memItemLeft" align="right" valign="top">vector&lt; vector&lt; double &gt; &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="graph_8cpp.html#ac83a486cf316213a12cbffd5598b2fdd">load_vertices</a> (const string &amp;path)</td></tr>
<tr class="separator:ac83a486cf316213a12cbffd5598b2fdd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5061393c1ae1c9773903ae2ac46adc0a"><td class="memItemLeft" align="right" valign="top">vector&lt; vector&lt; int &gt; &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="graph_8cpp.html#a5061393c1ae1c9773903ae2ac46adc0a">load_edges</a> (const string &amp;path)</td></tr>
<tr class="separator:a5061393c1ae1c9773903ae2ac46adc0a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a21228818f6b97bdd706d7980b74a2966"><td class="memItemLeft" align="right" valign="top">vector&lt; string &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="graph_8cpp.html#a21228818f6b97bdd706d7980b74a2966">split</a> (const string &amp;s)</td></tr>
<tr class="separator:a21228818f6b97bdd706d7980b74a2966"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Contains definitions of functions for representing the graph of paths and for path finding. </p>
</div><h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="a7f0876063956a2c9f083434f30d8abd3"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">vector&lt;int&gt; dijkstra </td>
          <td>(</td>
          <td class="paramtype">vector&lt; vector&lt; double &gt;&gt;&#160;</td>
          <td class="paramname"><em>graph</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>src</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>goal</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned long&#160;</td>
          <td class="paramname"><em>vnum</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Dijkstra's single source algorithm for a graph represented using adjacency matrix </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">graph</td><td>graph representation </td></tr>
    <tr><td class="paramname">src</td><td>source node index </td></tr>
    <tr><td class="paramname">vnum</td><td>number of vertices in the graph </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a9fba6aac78b4b7e5cddcc5c037ad6199"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">double evaluate_edge </td>
          <td>(</td>
          <td class="paramtype">vector&lt; double &gt;&#160;</td>
          <td class="paramname"><em>n1</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">vector&lt; double &gt;&#160;</td>
          <td class="paramname"><em>n2</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>flock_size</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">double&#160;</td>
          <td class="paramname"><em>gap</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Evaluates graph edge </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">n1</td><td>node #1 coordinates </td></tr>
    <tr><td class="paramname">n2</td><td>node #2 coordinates </td></tr>
    <tr><td class="paramname">flock_size</td><td>number of UAVs </td></tr>
    <tr><td class="paramname">gap</td><td>size of gap between obstacles around the edge </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>edge cost </dd></dl>

</div>
</div>
<a class="anchor" id="a4f76dec25df84647976b08cf172ab9b1"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">vector&lt;int&gt; find_path </td>
          <td>(</td>
          <td class="paramtype">const string &amp;&#160;</td>
          <td class="paramname"><em>fpath</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>flock_size</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>source_idx</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>goal_idx</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Main path finding function - loads graph and finds the shortest path from the start node to the end node </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">fpath</td><td>graph file path </td></tr>
    <tr><td class="paramname">flock_size</td><td>number of UAVs </td></tr>
    <tr><td class="paramname">source_idx</td><td>start node </td></tr>
    <tr><td class="paramname">goal_idx</td><td>end node </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>path as a vector of node indices </dd></dl>

</div>
</div>
<a class="anchor" id="a401501404aa387d4852fcc2a9ff3ad2d"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">vector&lt;int&gt; get_path </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>parent</em>[], </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>j</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">vector&lt; int &gt;&#160;</td>
          <td class="paramname"><em>out</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Function to find shortest path from source to j using parent array </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">parent</td><td>parent node array </td></tr>
    <tr><td class="paramname">j</td><td>goal node </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a5061393c1ae1c9773903ae2ac46adc0a"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">vector&lt;vector&lt;int&gt; &gt; load_edges </td>
          <td>(</td>
          <td class="paramtype">const string &amp;&#160;</td>
          <td class="paramname"><em>path</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Loads edges from the given file </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">path</td><td>file path </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>edges as vertex indices </dd></dl>

</div>
</div>
<a class="anchor" id="ac83a486cf316213a12cbffd5598b2fdd"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">vector&lt;vector&lt;double&gt; &gt; load_vertices </td>
          <td>(</td>
          <td class="paramtype">const string &amp;&#160;</td>
          <td class="paramname"><em>path</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Loads vertices from the given file (+converts mm to m) </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">path</td><td>file path </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>vertices coordinates </dd></dl>

</div>
</div>
<a class="anchor" id="a3fb0b3ab7cf6e09976ac5f8e075ade7a"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int minDistance </td>
          <td>(</td>
          <td class="paramtype">double&#160;</td>
          <td class="paramname"><em>dist</em>[], </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>sptSet</em>[], </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned long&#160;</td>
          <td class="paramname"><em>vnum</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>A utility function to find the vertex with minimum distance value, from the set of vertices not yet included in shortest path tree </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">dist</td><td>dist[i] = the shortest distance from src to i </td></tr>
    <tr><td class="paramname">sptSet</td><td>sptSet[i] = true if vertex i is included or in shortest path tree or shortest distance from src to i is finalized </td></tr>
    <tr><td class="paramname">vnum</td><td>number of vertices in the graph </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>index of closest vertex </dd></dl>

</div>
</div>
<a class="anchor" id="a21228818f6b97bdd706d7980b74a2966"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">vector&lt;string&gt; split </td>
          <td>(</td>
          <td class="paramtype">const string &amp;&#160;</td>
          <td class="paramname"><em>s</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Utility function for string splitting using spaces as delimiter </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">s</td><td>input string </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>vector of words </dd></dl>

</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.11
</small></address>
</body>
</html>
